El comando dotnet no se puede ejecutar después de instalar snap
Seguí estas instrucciones para instalar la vista previa de .NET 6.0 usando snap.
Después de la instalación, cuando intento ejecutar el comando dotnet, aparece el siguiente mensaje de error:
no se puede ejecutar snap: no se puede ejecutar "/snap/dotnet-sdk/152/snap/command-chain/snapcraft-runner": permiso denegado Esto se debe a que el directorio /snap/dotnet-sdk/152/snap solo es accesible por root y es un sistema de archivos montado, por lo que no es posible cambiarlo.
Estoy usando una instalación nueva de Ubuntu 20.04, por lo que no debería haber ningún otro conflicto.
# Install the .NET 6 SDK as a snap package. # The snap package will automatically be mounted. snap install dotnet-sdk --channel=6.0/beta --classic # Try running the snap command. If this works, you do not have to # apply the workaround. If this fails, continue. dotnet-sdk.dotnet --version # To find out where the snap package has been mounted, # list all block devices and look for /snap/dotnet-sdk/ # in the MOUNTPOINT column. Remember the name of the loop # device. lsblk # To get the actual path of the snap package file, run # The path in the BACK-FILE column points to the snap package. losetup --list # Replace XXX with the number of your snap. # find the /var/lib/snapd/snaps/dotnet-sdk_XXX.snap in the list # Create a folder where we're extracting the snap package into. mkdir dotnet-snap-fix cd dotnet-snap-fix # Extract the snap package into this directory. # Add the correct BACK-FILE path to your snap package here. # Replace XXX or the whole path with the BACK-FILE displayed by # the losetup command above. sudo unsquashfs /var/lib/snapd/snaps/dotnet-sdk_XXX.snap # Change the permissions of the snap folder containing the runner # to be readable and executable. This will fix the permission problem. sudo chmod -R +rx ./squashfs-root/snap/ # Create a new snap package with the changed permissions. # Make sure to use the same file name as in the BACK-FILE path. # Replace XXX or the whole file name with the file name of the # BACK-FILE path displayed by the losetup command above. sudo mksquashfs ./squashfs-root/ dotnet-sdk_XXX.snap -comp xz -all-root # Overwrite the old snap package with our new one. # Make sure the file name is correct (same as in BACK-FILE). sudo mv ./dotnet-sdk_XXX.snap /var/lib/snapd/snaps/ # Finally reboot your machine so the changes are detected. sudo reboot # Do not use snap disable / snap enable, they will replace the # fixed snap package with the broken one again. # After the reboot, the dotnet-sdk.dotnet command will work without sudo. dotnet-sdk.dotnetreferencia a la solución: https://github.com/dotnet/core/issues/4446#issuecomment-605629427
Parece ser un problema con el alias de complemento. Simplemente elimine el alias del complemento y enlace simbólico al binario en su lugar.
sudo snap unalias dotnet sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet Entonces debería poder llamar a dotnet --list-sdks sin permiso de root.